package com.mall.common.interceptor;

import com.mall.common.contants.InterecptorConstant;
import com.mall.common.context.RunTimeConttentData;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;

public class CommonInterceptor implements HandlerInterceptor {


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String userId = request.getHeader(InterecptorConstant.PARA_USER_ID);
        RunTimeConttentData data = RunTimeConttentData.getInstance();
        data.setUserId(userId);
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }
}
